package com.hmkj.admin.controller.amount;

import com.hmkj.admin.controller.BaseController;
import com.hmkj.admin.controller.GenericController;
import com.hmkj.common.entity.ResultEntity;
import com.hmkj.common.entity.dtgrid.DtGrid;
import com.hmkj.common.entity.export.ExportUtils;
import com.hmkj.core.constant.Constants;
import com.hmkj.core.model.amount.AccountLogModel;
import com.hmkj.core.model.amount.AccountModel;
import com.hmkj.core.po.amount.AccountLog;
import com.hmkj.core.service.amount.AccountLogService;
import com.hmkj.core.service.user.UserService;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

/**
 * 资金记录
 *
 * @author zhaxiaowei
 * @create 2017-06-21 21:42
 **/
@Controller
@RequestMapping(BaseController.BASE_URI)
public class AccountLogJsonController extends GenericController<Integer, AccountLog> {

    @Resource
    private AccountLogService accountLogService;

    @Resource
    UserService userService;

    /**
     * 资金记录列表json数据
     *
     * @param dtGridPager
     * @return
     * @throws Exception
     */
    @ResponseBody
    @RequestMapping("accountlog/json/list")
    @RequiresPermissions("sys:accountlog:list")
    public DtGrid listJson(String dtGridPager) throws Exception {
        DtGrid dtgrid = dataAuthority(dtGridPager, Constants.AG);
        return accountLogService.getDtGridList(dtgrid, AccountLogModel.class);
    }
    /**
     * 列表导出
     *
     * @param dtGridPager
     * @return
     */
    @ResponseBody
    @RequestMapping(value = "accountlog/json/export", method = RequestMethod.POST)
    public ResultEntity export(String dtGridPager, HttpServletRequest request, HttpServletResponse response) throws Exception {
        // 执行导出
        ExportUtils.export(request, response, accountLogService.getDtGridListExport(dtGridPager,AccountLogModel.class));
        return ok();
    }
}
